package wcg;

import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;


public class SimpleTable extends JTable {

	/**
	 * 
	 * @author ikechan
	 *
	 */
	public class CustomTableModel extends DefaultTableModel {
		private static final long serialVersionUID = 1L;
	    CustomTableModel(Object[][] tableData, String[] tableColumnName) {
			super(tableData,tableColumnName);
		}
	    CustomTableModel(){
	    	super();
	    }
		public Class<?> getColumnClass(int col){
			switch(col){
			case 0: return String.class;
			default: return Integer.class;
			}
		}
		
	}

	
	
	private void onInitial(){
		setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
		setColumnSelectionAllowed(true);
		getTableHeader().setReorderingAllowed(true);
		
	}
	public SimpleTable() {
		super();
		onInitial();
	}
	public void setColumn(String[] colum){
		for(int i=0;i<colum.length;i++){
			TableColumn c = new TableColumn();
			c.setHeaderValue(colum[i]);
			addColumn(c);
		}
	}
}
